home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / PRAY.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  38KB  |  1,312 lines

  1. /*    SCCS Id: @(#)pray.c    3.0    89/11/20
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
  4. /* NetHack may be freely redistributed.  See license for details. */
  5.  
  6. #include "hack.h"
  7.  
  8. #ifdef THEOLOGY
  9. static int NDECL(in_trouble);
  10. static void FDECL(fix_worst_trouble,(int));
  11. static void NDECL(angrygods);
  12. static void NDECL(pleased);
  13. static void NDECL(gods_upset);
  14. static void FDECL(consume_offering,(struct obj *));
  15.  
  16. #define ALIGNLIM     (5L + (moves/200L))
  17.  
  18. struct ghods {
  19.     char    classlet;
  20.     const char *law, *balance, *chaos;
  21. }  gods[] = {
  22.  
  23. 'A', /* Central American */    "Quetzalcotl", "Camaxtli", "Huhetotl",
  24. 'B', /* Celtic */        "Nuada", "Dagda", "Morrigan",
  25. 'C', /* Babylonian */        "Anu", "Ishtar", "Anshar",
  26. 'E', /* Elven */        "Solonor Thelandira",
  27.                 "Aerdrie Faenya", "Erevan Ilesere",
  28. 'H', /* Greek */        "Athena", "Hermes", "Poseidon",
  29. 'K', /* Celtic */        "Lugh", "Brigit", "Macannan Mac Lir",
  30. #ifdef NAMED_ITEMS
  31. /* It'd look funny if someone got a sword to steal souls for Arioch but Arioch
  32.  * goes with the wrong character class...
  33.  */
  34. 'P', /* Hyborian */        "Mitra", "Crom", "Set",
  35. #else
  36. 'P', /* Melnibonean */        "Donblas", "Grome", "Arioch",
  37. #endif
  38. 'R', /* Nehwon */        "Votishal", "Death", "Rat God",
  39. 'S', /* Japanese */        "Amaterasu Omikami", "Raiden", "Susanowo",
  40. 'T', /* Chinese */        "Shan Lai Ching", "Chih Sung-tzu", "Huan Ti",
  41. 'V', /* Norse */        "Tyr", "Balder", "Loki",
  42. 'W', /* Egyptian */        "Ptah", "Thoth", "Anhur",
  43. 0,0,0,0
  44. };
  45.  
  46. #define TROUBLE_STONED 9
  47. #define TROUBLE_STRANGLED 8
  48. #define TROUBLE_SICK 7
  49. #define TROUBLE_STARVING 6
  50. #define TROUBLE_HIT 5
  51. #define TROUBLE_LYCANTHROPE 4
  52. #define TROUBLE_STUCK_IN_WALL 3
  53. #define TROUBLE_CURSED_BLINDFOLD 2
  54. #define TROUBLE_CURSED_LEVITATION 1
  55.  
  56. #define TROUBLE_PUNISHED (-1)
  57. #define TROUBLE_CURSED_ITEMS (-2)
  58. #define TROUBLE_BLIND (-3)
  59. #define TROUBLE_HUNGRY (-4)
  60. #define TROUBLE_POISONED (-5)
  61. #define TROUBLE_WOUNDED_LEGS (-6)
  62. #define TROUBLE_STUNNED (-7)
  63. #define TROUBLE_CONFUSED (-8)
  64. #define TROUBLE_HALLUCINATION (-9)
  65.  
  66. /* We could force rehumanize of polyselfed people, but we can't tell
  67.    unintentional shape changes from the other kind. Oh well. */
  68.  
  69. /* Return 0 if nothing particular seems wrong, positive numbers for
  70.    serious trouble, and negative numbers for comparative annoyances. This
  71.    returns the worst problem. There may be others, and the gods may fix
  72.    more than one.
  73.  
  74. This could get as bizarre as noting surrounding opponents, (or hostile dogs),
  75. but that's really hard.
  76.  */
  77.  
  78. #define ugod_is_angry() (u.ualign < 0)
  79. #ifdef ALTARS
  80. #define on_altar()    IS_ALTAR(levl[u.ux][u.uy].typ)
  81. #define on_shrine()    ((levl[u.ux][u.uy].altarmask & A_SHRINE) != 0)
  82. #endif
  83.  
  84. static int
  85. in_trouble()
  86. {
  87.     register struct obj *otmp;
  88.     int i, j, count=0;
  89.  
  90. /* Borrowed from eat.c */
  91.  
  92. #define    SATIATED    0
  93. #define NOT_HUNGRY    1
  94. #define    HUNGRY        2
  95. #define    WEAK        3
  96. #define    FAINTING    4
  97. #define FAINTED        5
  98. #define STARVED        6
  99.  
  100.     if(Stoned) return(TROUBLE_STONED);
  101.     if(Strangled) return(TROUBLE_STRANGLED);
  102.     if(Sick) return(TROUBLE_SICK);
  103.     if(u.uhs >= WEAK) return(TROUBLE_STARVING);
  104.     if(u.uhp < 5 || (u.uhp*7 < u.uhpmax)) return(TROUBLE_HIT);
  105.     for (i= -1; i<=1; i++) for(j= -1; j<=1; j++) {
  106.         if (!i && !j) continue;
  107.         if (!isok(u.ux+i, u.uy+j) || IS_ROCK(levl[u.ux+i][u.uy+j].typ))
  108.             count++;
  109.     }
  110. #ifdef POLYSELF
  111.     if(u.ulycn >= 0) return(TROUBLE_LYCANTHROPE);
  112. #endif
  113.     if(count==8
  114. #ifdef POLYSELF
  115.         && !passes_walls(uasmon)
  116. #endif
  117.         ) return(TROUBLE_STUCK_IN_WALL);
  118.     if((uarmf && uarmf->otyp==LEVITATION_BOOTS && uarmf->cursed) ||
  119.         (uleft && uleft->otyp==RIN_LEVITATION && uleft->cursed) ||
  120.         (uright && uright->otyp==RIN_LEVITATION && uright->cursed))
  121.         return(TROUBLE_CURSED_LEVITATION);
  122.     if(ublindf && ublindf->cursed) return(TROUBLE_CURSED_BLINDFOLD);
  123.  
  124.     if(Punished) return(TROUBLE_PUNISHED);
  125.     for(otmp=invent; otmp; otmp=otmp->nobj)
  126.         if((otmp->otyp==LOADSTONE || otmp->otyp==LUCKSTONE) &&
  127.             otmp->cursed) 
  128.             return(TROUBLE_CURSED_ITEMS);
  129.     if((uarmh && uarmh->cursed) ||    /* helmet */
  130.        (uarms && uarms->cursed) ||    /* shield */
  131.        (uarmg && uarmg->cursed) ||    /* gloves */
  132.        (uarm && uarm->cursed) ||    /* armor */
  133.        (uarmc && uarmc->cursed) ||    /* cloak */
  134.        (uarmf && uarmf->cursed && uarmf->otyp != LEVITATION_BOOTS) ||
  135.                     /* boots */
  136. #ifdef SHIRT
  137.        (uarmu && uarmu->cursed) ||  /* shirt */
  138. #endif
  139.        (uwep && welded(uwep)) ||
  140.        (uleft && uleft->cursed && uleft->otyp != RIN_LEVITATION) ||
  141.        (uright && uright->cursed && uright->otyp != RIN_LEVITATION) ||
  142.        (uamul && uamul->cursed))
  143.  
  144.        return(TROUBLE_CURSED_ITEMS);
  145.  
  146.     if(Blinded > 1) return(TROUBLE_BLIND);
  147.     if(u.uhs >= HUNGRY) return(TROUBLE_HUNGRY);
  148.     for(i=0; i<A_MAX; i++)
  149.         if(ABASE(i) < AMAX(i)) return(TROUBLE_POISONED);
  150.     if(Wounded_legs) return (TROUBLE_WOUNDED_LEGS);
  151.     if(HStun) return (TROUBLE_STUNNED);
  152.     if(HConfusion) return (TROUBLE_CONFUSED);
  153.     if(Hallucination) return(TROUBLE_HALLUCINATION);
  154.  
  155.     return(0);
  156. }
  157.  
  158. const char leftglow[] = "left ring softly glows";
  159. const char rightglow[] = "right ring softly glows";
  160.  
  161. static void
  162. fix_worst_trouble(trouble)
  163. register int trouble;
  164. {
  165.     int i;
  166.     struct obj *otmp = (struct obj *)0;
  167.     const char *what = NULL;
  168.  
  169.     u.ublesscnt += rnz(100);
  170.     switch (trouble) {
  171.         case TROUBLE_STONED:
  172.             You("feel more limber.");
  173.             Stoned = 0;
  174.             break;
  175.         case TROUBLE_STRANGLED:
  176.             You("can breathe again.");
  177.             Strangled = 0;
  178.             break;
  179.         case TROUBLE_HUNGRY:
  180.         case TROUBLE_STARVING:
  181.             Your("stomach feels content.");
  182.             init_uhunger ();
  183.             losestr(-1);
  184.             flags.botl = 1;
  185.             break;
  186.         case TROUBLE_SICK:
  187.             You("feel better.");
  188.             make_sick(0L,FALSE);
  189.             break;
  190.         case TROUBLE_HIT:
  191.             if (!Blind) {
  192.             pline("%s glow surrounds you.",
  193.                   An(Hallucination ? hcolor() : golden));
  194.             } else You("feel much better.");
  195.             if (u.uhpmax < u.ulevel * 5 + 11)
  196.             u.uhp = u.uhpmax += rnd(5);
  197.             else
  198.             u.uhp = u.uhpmax;
  199.             flags.botl = 1;
  200.             break;
  201.         case TROUBLE_STUCK_IN_WALL:
  202.             Your("surroundings change.");
  203.             tele();
  204.             break;
  205.         case TROUBLE_CURSED_LEVITATION:
  206.             if (uarmf && uarmf->otyp==LEVITATION_BOOTS
  207.                         && uarmf->cursed)
  208.             otmp = uarmf;
  209.             else if (uleft && uleft->otyp==RIN_LEVITATION
  210.                         && uleft->cursed) {
  211.             otmp = uleft;
  212.             what = leftglow;
  213.             } else {
  214.             otmp = uright;
  215.             what = rightglow;
  216.             }
  217.             goto decurse;
  218.         case TROUBLE_CURSED_BLINDFOLD:
  219.             otmp = ublindf;
  220.             goto decurse;
  221.         case TROUBLE_PUNISHED:
  222.             Your("chain disappears.");
  223.             unpunish();
  224.             break;
  225. #ifdef POLYSELF
  226.         case TROUBLE_LYCANTHROPE:
  227.             You("feel purified.");
  228.             if(uasmon == &mons[u.ulycn] && !Polymorph_control)
  229.             rehumanize();
  230.             u.ulycn = -1;       /* now remove the curse */
  231.             break;
  232. #endif
  233.         case TROUBLE_CURSED_ITEMS:
  234.             if (uarmh && uarmh->cursed)     /* helmet */
  235.                 otmp = uarmh;
  236.             else if (uarms && uarms->cursed) /* shield */
  237.                 otmp = uarms;
  238.             else if (uarmg && uarmg->cursed) /* gloves */
  239.                 otmp = uarmg;
  240.             else if (uarm && uarm->cursed) /* armor */
  241.                 otmp = uarm;
  242.             else if (uarmc && uarmc->cursed) /* cloak */
  243.                 otmp = uarmc;
  244.             else if (uarmf && uarmf->cursed) /* boots */
  245.                 otmp = uarmf;
  246. #ifdef SHIRT
  247.             else if (uarmu && uarmu->cursed) /* shirt */
  248.                 otmp = uarmu;
  249. #endif
  250.             else if (uleft && uleft->cursed) {
  251.                 otmp = uleft;
  252.                 what = leftglow;
  253.             } else if (uright && uright->cursed) {
  254.                 otmp = uright;
  255.                 what = rightglow;
  256.             } else if (uamul && uamul->cursed) /* amulet */
  257.                 otmp = uamul;
  258.             else if (welded(uwep)) otmp = uwep;
  259.             else {
  260.                 for(otmp=invent; otmp; otmp=otmp->nobj)
  261.                 if ((otmp->otyp==LOADSTONE ||
  262.                      otmp->otyp==LUCKSTONE) && otmp->cursed)
  263.                     break;
  264.             }
  265. decurse:
  266.             otmp->cursed = 0;
  267.             otmp->bknown = 1;
  268.             if (!Blind)
  269.                 Your("%s %s.",
  270.                    what ? what : (const char *)aobjnam (otmp, "softly glow"),
  271.                 Hallucination ? hcolor() : amber);
  272.             break;
  273.         case TROUBLE_HALLUCINATION:
  274.             pline ("Looks like you are back in Kansas.");
  275.             make_hallucinated(0L,FALSE);
  276.             break;
  277.         case TROUBLE_BLIND:
  278.             Your("%s feel better.", makeplural(body_part(EYE)));
  279.             make_blinded(0L,FALSE);
  280.             break;
  281.         case TROUBLE_POISONED:
  282.             if (Hallucination)
  283.             pline("There's a tiger in your tank.");
  284.             else
  285.             You("feel in good health again.");
  286.             for(i=0; i<A_MAX; i++) {
  287.             if(ABASE(i) < AMAX(i)) {
  288.                 ABASE(i) = AMAX(i);
  289.                 flags.botl = 1;
  290.             }
  291.             }
  292.             break;
  293.         case TROUBLE_WOUNDED_LEGS:
  294.             heal_legs();
  295.             break;
  296.         case TROUBLE_STUNNED:
  297.             make_stunned(0L,TRUE);
  298.             break;
  299.         case TROUBLE_CONFUSED:
  300.             make_confused(0L,TRUE);
  301.             break;
  302.     }
  303. }
  304.  
  305. static void
  306. angrygods() {
  307.     register int    tmp;
  308.  
  309.     u.ublessed = 0;
  310.  
  311.     /* changed from tmp = u.ugangr + abs (u.uluck) -- rph */
  312.     tmp =  3*u.ugangr +
  313.            (Luck > 0 || u.ualign > 3 ? -Luck/3 : -Luck);
  314.     if (tmp < 0) tmp = 0; /* possible if bad alignment but good luck */
  315.     tmp =  (tmp > 15 ? 15 : tmp);  /* lets be a little reasonable */
  316.     switch (tmp ? rn2(tmp): 0) {
  317.  
  318.         case 0:
  319.         case 1:    if (Hallucination)
  320.                 You("feel a%sholy dread.",
  321.                   u.ualigntyp == U_CHAOTIC ? "n un" : " ");
  322.             else You("feel that %s is %s.",
  323. #  ifdef ALTARS
  324.                    on_altar() ? a_gname() : u_gname(),
  325. #  else
  326.                    u_gname(),
  327. #  endif
  328.                    u.ualigntyp == U_NEUTRAL ? "offended" : "angry");
  329.             break;
  330.         case 2:
  331.         case 3:
  332.             pline("A voice thunders:");
  333. # ifdef POLYSELF
  334.             pline("\"Thou %s, %s.\"",
  335.                   ugod_is_angry() ? "hast strayed from the path" :
  336.                             "art arrogant",
  337.                   u.usym == S_HUMAN ? "mortal" : "creature");
  338. # else
  339.             pline("\"Thou %s, mortal.\"",
  340.                   ugod_is_angry() ? "hast strayed from the path" :
  341.                             "art arrogant");
  342. # endif
  343.             verbalize("Thou must relearn thy lessons!");
  344.             adjattrib(A_WIS, -1, FALSE);
  345.             if (u.ulevel > 1) {
  346.                 losexp();
  347.                 if(u.uhp < 1) u.uhp = 1;
  348.                 if(u.uhpmax < 1) u.uhpmax = 1;
  349.             } else  {
  350.                 u.uexp = 0;
  351.                 flags.botl = 1;
  352.             }
  353.             break;
  354.         case 6:    if (!Punished) {
  355.                 punish((struct obj *)0);
  356.                 break;
  357.             } /* else fall thru */
  358.         case 4:
  359.         case 5:    if (!Blind)
  360.                 pline("%s glow surrounds you.",
  361.                   An(Hallucination ? hcolor() : black));
  362.             rndcurse();
  363.             break;
  364.         case 7:
  365.         case 8:    pline("A voice booms out:");
  366.             verbalize("Thou durst call upon me?");
  367. # ifdef POLYSELF
  368.             pline("\"Then die, %s!\"",
  369.                   u.usym == S_HUMAN ? "mortal" : "creature");
  370. # else
  371.             verbalize("Then die, mortal!");
  372. # endif
  373.             (void) makemon(&mons[ndemon()], u.ux, u.uy);
  374.             break;
  375.  
  376.         default:    pline("Suddenly, a bolt of lightning strikes you!");
  377.             if (Reflecting) {
  378.                 shieldeff(u.ux, u.uy);
  379.                 if (Blind)
  380.                 pline("For some reason you're unaffected.");
  381.                 else {
  382.                 if (Reflecting & W_AMUL) {
  383.                     pline("It reflects from your medallion.");
  384.                     makeknown(AMULET_OF_REFLECTION);
  385.                 } else {
  386.                     pline("It reflects from your shield.");
  387.                     makeknown(SHIELD_OF_REFLECTION);
  388.                 }
  389.                 }
  390.     You("hear a cosmic sigh, and sense a decision being made.");
  391.     pline("A wide-angle disintegration beam hits you!");
  392.     goto ohno;
  393.             } else if (Shock_resistance) {
  394.                 shieldeff(u.ux, u.uy);
  395.                 pline("It seems not to affect you.");
  396.             pline("However, the ensuing disintegration beam does.");
  397. ohno:
  398.                 if (Disint_resistance) {
  399.     You("bask in the disintegration beam for a minute...");
  400.                     pline("A voice rings out:");
  401.                     verbalize("I believe it not!");
  402.                     break;
  403.                 }
  404.             }
  405.             You("fry to a crisp.");
  406.             killer_format = KILLED_BY_AN;
  407.             killer = "holy wrath";
  408.             done(DIED);
  409.             break;
  410.     }
  411.     u.ublesscnt = rnz(300);
  412.     return;
  413. }
  414.  
  415. static void
  416. pleased() {
  417.     int trouble = in_trouble ();    /* what's your worst difficulty? */
  418.     int pat_on_head = 0;
  419.  
  420.     You("feel that %s is pleased.",
  421. #ifndef ALTARS
  422.            u_gname());
  423. #else
  424.            on_altar() ? a_gname() : u_gname());
  425.  
  426.     /* not your deity */
  427.     if (on_altar() &&
  428.         (levl[u.ux][u.uy].altarmask & ~A_SHRINE) != u.ualigntyp + 1) {
  429.         adjalign(-1);
  430.         return;
  431.     } else if (u.ualign < 2) adjalign(1);
  432. #endif
  433.  
  434.  
  435.     /* depending on your luck, the gods will:
  436.        - fix your worst problem if it's major.
  437.        - fix all your major problems.
  438.        - fix your worst problem if it's minor.
  439.        - fix all of your problems.
  440.        - do you a gratuitous favor.
  441.  
  442.        if you make it to the the last category, you roll randomly again
  443.        to see what they do for you.
  444.  
  445.        If your luck is at least 0, then you are guaranteed rescued
  446.        from your worst major problem. */
  447.  
  448.     if (!trouble) pat_on_head = 1;
  449.     else {
  450. #ifdef ALTARS
  451.         int action = rn1(on_altar() ? 3 + on_shrine() : 2, Luck+1);
  452.  
  453.         if (!on_altar()) action = max(action,2);
  454. #else
  455.         int action = rn1(4,Luck+1);
  456. #endif
  457.  
  458.         switch(min(action,5)) {
  459.         case 5: pat_on_head = 1;
  460.         case 4: do fix_worst_trouble(trouble);
  461.             while(trouble = in_trouble());
  462.             break;
  463.  
  464.         case 3: fix_worst_trouble(trouble);
  465.         case 2: while((trouble = in_trouble()) > 0)
  466.                 fix_worst_trouble(trouble);
  467.             break;
  468.  
  469.         case 1: if (trouble > 0) fix_worst_trouble(trouble);
  470.         }
  471.     }
  472.  
  473.     if(pat_on_head)
  474.     switch(rn2((Luck + 6)>>1))  {
  475.  
  476.         case 0:    break;
  477.         case 1:
  478.             if(uwep && (uwep->olet == WEAPON_SYM || uwep->otyp
  479.                 == PICK_AXE) && (!uwep->blessed)) {
  480.                 if (uwep->cursed) {
  481.                 uwep->cursed = 0;
  482.                 uwep->bknown = 1;
  483.                 if (!Blind)
  484.                     Your("%s %s.",
  485.                       aobjnam(uwep, "softly glow"),
  486.                       Hallucination ? hcolor() : amber);
  487.                 } else if(uwep->otyp < BOW) {
  488.                 uwep->blessed = uwep->bknown = 1;
  489.                 if (!Blind) {
  490.                     Your("%s with %s aura.",
  491.                       aobjnam(uwep, "softly glow"),
  492.                       an(Hallucination ? hcolor() : light_blue));
  493.                 }
  494.                 }
  495.             }
  496.             break;
  497.         case 3:
  498. #if defined(STRONGHOLD) && defined(MUSIC)
  499.             /* takes 2 hints to get the music to enter the stronghold */
  500.             if (flags.soundok) {
  501.                 if(music_heard < 1) {
  502.                 pline("A voice rings out:");
  503. # ifdef POLYSELF
  504.                 pline("\"Hark, %s!\"",
  505.                     u.usym == S_HUMAN ? "mortal" : "creature");
  506. # else
  507.                 verbalize("Hark, mortal!");
  508. # endif
  509.                 verbalize("To enter the castle, thou must play the right tune!");
  510.                 music_heard++;
  511.                 break;
  512.                 } else if (music_heard < 2) {
  513.                 You("hear a divine music...");
  514.                 pline("It sounds like:  \"%s\".", tune);
  515.                 music_heard++;
  516.                 break;
  517.                 }
  518.             }
  519.             /* Otherwise, falls into next case */
  520. #endif
  521.         case 2:    if (!Blind)
  522.                 You("are surrounded by %s glow.",
  523.                 an(Hallucination ? hcolor() : golden));
  524.             u.uhp = u.uhpmax += 5;
  525.             ABASE(A_STR) = AMAX(A_STR);
  526.             if (u.uhunger < 900)    init_uhunger();
  527.             if (u.uluck < 0)    u.uluck = 0;
  528.             make_blinded(0L,TRUE);
  529.             flags.botl = 1;
  530.             break;
  531.         case 4:
  532.         {    register struct obj *otmp;
  533.  
  534.             if (Blind)
  535.                 You("feel the power of %s.", u_gname());
  536.             else You("are surrounded by %s aura.",
  537.                  an(Hallucination ? hcolor() : light_blue));
  538.             for(otmp=invent; otmp; otmp=otmp->nobj) {
  539.                 if (otmp->cursed) {
  540.                     otmp->cursed = 0;
  541.                     if (!Blind)
  542.                     Your("%s %s.",
  543.                           aobjnam(otmp, "softly glow"),
  544.                           Hallucination ? hcolor() : amber);
  545.                 }
  546.             }
  547.             break;
  548.         }
  549.         case 5:
  550.         {
  551.             const char *msg="\"and thus I grant thee the gift of %s!\"";
  552.             pline("A voice booms out:");
  553.             verbalize("Thou hast pleased me with thy progress,");
  554.             if (!(HTelepat & INTRINSIC))  {
  555.                 HTelepat |= INTRINSIC;
  556.                 pline(msg, "Telepathy");
  557.             } else if (!(Fast & INTRINSIC))  {
  558.                 Fast |= INTRINSIC;
  559.                 pline(msg, "Speed");
  560.             } else if (!(Stealth & INTRINSIC))  {
  561.                 Stealth |= INTRINSIC;
  562.                 pline(msg, "Stealth");
  563.             } else {
  564.                 if (!(Protection & INTRINSIC))  {
  565.                 Protection |= INTRINSIC;
  566.                 if (!u.ublessed)  u.ublessed = rnd(3) + 1;
  567.                 } else u.ublessed++;
  568.                 pline(msg, "my protection");
  569.             }
  570.             verbalize("Use it wisely in my name!");
  571.             break;
  572.         }
  573.         case 7:
  574.         case 8:
  575. #ifdef ELBERETH
  576.             if (u.ualign > 3 && !u.uhand_of_elbereth) {
  577.                 u.uhand_of_elbereth = TRUE;
  578.                 HSee_invisible |= INTRINSIC;
  579.                 HFire_resistance |= INTRINSIC;
  580.                 HCold_resistance |= INTRINSIC;
  581.                 HPoison_resistance |= INTRINSIC;
  582.                 pline("A voice booms out:");
  583.                 if (u.ualigntyp != U_CHAOTIC) {
  584.                 verbalize("I crown thee...      The Hand of Elbereth!");
  585. #ifdef NAMED_ITEMS
  586.                 if(uwep && (uwep->otyp == LONG_SWORD)) {
  587.                     bless(uwep);
  588.                     uwep->bknown = 1;
  589.                     uwep->rustfree = 1;
  590.                     (void)oname(uwep, "Excalibur", 1);
  591.                 }
  592. #endif
  593.                 } else {
  594.                 register struct obj *obj;
  595. #ifdef NAMED_ITEMS
  596.                 const char *Stormbringer = "Stormbringer";
  597.  
  598.                 /* This does the same damage as Excalibur.
  599.                  * Disadvantages: doesn't do bonuses to undead;
  600.                  * doesn't aid searching.
  601.                  * Advantages: part of that bonus is a level
  602.                  * drain.
  603.                  * Disadvantage: player cannot start with a
  604.                  * +5 weapon and turn it into a Stormbringer.
  605.                  * Advantage: they don't need to already have a
  606.                  * sword of the right type to get it...
  607.                  * However, if Stormbringer already exists in
  608.                  * the game, an ordinary good broadsword is
  609.                  * given and the messages are a bit different.
  610.                  */
  611.                 obj = mksobj(BROADSWORD, FALSE);
  612.                 if (exist_artifact(obj, Stormbringer))
  613.                     verbalize("Thou art chosen to take lives for Arioch!");
  614.                 else
  615.                     verbalize("Thou art chosen to steal souls for Arioch!");
  616.                 if (Blind)
  617.                     pline("Something appears at your %s.",
  618.                     makeplural(body_part(FOOT)));
  619.                 else
  620.                     pline("%s sword appears at your %s!",
  621.                     An(exist_artifact(obj, Stormbringer) ?
  622.                        (const char *)"wide" :
  623.                        Hallucination ? hcolor() : black),
  624.                     makeplural(body_part(FOOT)));
  625.                 obj->rustfree = 1;
  626.                 obj->cursed = 0;
  627.             /* Why bless it?  Why not.  After all, chaotic gods
  628.              * will bless regular weapons.  And blessed really
  629.              * means given sanctified to a deity, which is certainly
  630.              * sensible even for Stormbringer and a chaotic deity...
  631.              */
  632.                 obj->blessed = 1;
  633.  
  634.                 /* if not "Stormbringer", make it a bit better otherwise */
  635.                 if (exist_artifact(obj, Stormbringer))
  636.                     obj->spe = 3;
  637.                 else
  638.                     obj->spe = 1;
  639.                 /* existence of "Stormbringer" is checked in oname() */
  640.                 obj = oname(obj, Stormbringer, 0);
  641.                 dropy(obj);
  642. #else
  643.                 verbalize("Thou shalt become the servant of Arioch!");
  644. #endif
  645.                 }
  646.                 break;
  647.             }
  648. #endif
  649.  
  650.         case 6:    pline ("An object appears at your %s!",
  651.                 makeplural(body_part(FOOT)));
  652. #ifdef SPELLS
  653.             bless(mkobj_at(SPBOOK_SYM, u.ux, u.uy, TRUE));
  654. #else
  655.             bless(mkobj_at(SCROLL_SYM, u.ux, u.uy, TRUE));
  656. #endif
  657.             break;
  658.  
  659.         default:    impossible("Confused deity!");
  660.             break;
  661.     }
  662.     u.ublesscnt = rnz(350);
  663. #ifdef HARD
  664. # ifndef ELBERETH
  665.     u.ublesscnt += (u.udemigod * rnz(1000));
  666. # else
  667.     u.ublesscnt += ((u.udemigod + u.uhand_of_elbereth) * rnz(1000));
  668. # endif
  669. #endif
  670.     return;
  671. }
  672.  
  673. static void
  674. gods_upset()
  675. {
  676. #ifdef HARD
  677.     u.ugangr++;
  678.     angrygods();
  679. #else
  680.     if (u.ugangr++)    angrygods();
  681.     else {            /* exactly one warning */
  682. # ifdef ALTARS
  683.         pline("The voice of %s booms out:",
  684.                 on_altar() ? a_gname() : u_gname());
  685. # else
  686.         pline("A voice booms out:");
  687. # endif
  688.         verbalize("Thou hast angered me.");
  689.         verbalize("Disturb me again at thine own peril!");
  690.     }
  691. #endif
  692. }
  693.  
  694. #ifdef ENDGAME
  695. static const char NEARDATA sacrifice_types[] = { FOOD_SYM, AMULET_SYM, 0 };
  696. #endif
  697.  
  698. static void
  699. consume_offering(otmp)
  700. register struct obj *otmp;
  701. {
  702.     if (Hallucination)
  703.         Your("sacrifice sprouts wings and a propeller and roars away!");
  704.     else if (Blind && u.ualigntyp == U_LAWFUL)
  705.         Your("sacrifice disappears!");
  706.     else Your("sacrifice is consumed in a %s!",
  707.             u.ualigntyp == U_LAWFUL ? "flash of light" : "burst of flame");
  708.     if (carried(otmp)) useup(otmp);
  709.     else useupf(otmp);
  710. }
  711.  
  712. int
  713. dosacrifice()
  714. {
  715.     register struct obj *otmp;
  716.     int value = 0;
  717. #ifdef ALTARS
  718.     /* Note: normal altar aligns are 0, 1, 2; this is -1, 0, 1 so it */
  719.     /* can be compared with u.ualigntyp */
  720.     int altaralign = (levl[u.ux][u.uy].altarmask & ~A_SHRINE) - 1;
  721.  
  722.     if (!on_altar()) {
  723.         You("are not standing on an altar.");
  724.         return 0;
  725.     }
  726. #endif /* ALTARS /**/
  727.  
  728. #ifdef ENDGAME
  729.     if (dlevel == ENDLEVEL) {
  730.         if (!(otmp = getobj(sacrifice_types, "sacrifice"))) return 0;
  731.     } else
  732.         if (!(otmp = floorfood("sacrifice", 0))) return 0;
  733. #else
  734.     if (!(otmp = floorfood("sacrifice", 0))) return 0;
  735. #endif
  736. /*
  737.    Was based on nutritional value and aging behavior (< 50 moves).
  738.    Sacrificing a food ration got you max luck instantly, making the
  739.    gods as easy to please as an angry dog!
  740.  
  741.    Now only accepts corpses, based on the games evaluation of their
  742.    toughness.  Human sacrifice, as well as sacrificing unicorns of
  743.    your alignment, is strongly discouraged.  (We can't tell whether
  744.    a pet corpse was tame, so you can still sacrifice it.)
  745.  */
  746.  
  747. #define MAXVALUE 24    /* Highest corpse value (besides Wiz) */
  748.  
  749.     if (otmp->otyp == CORPSE) {
  750.         register struct permonst *mtmp = &mons[otmp->corpsenm];
  751.         extern int monstr[];
  752.  
  753.         if (otmp->corpsenm == PM_ACID_BLOB || (monstermoves <= otmp->age + 50))
  754.         value = monstr[otmp->corpsenm] + 1;
  755.         if (otmp->oeaten)
  756.         value = eaten_stat(value, otmp);
  757.  
  758.         if (is_human(mtmp)) { /* Human sacrifice! */
  759. #ifdef POLYSELF
  760.         if (is_demon(uasmon))
  761.             You("find the idea very satisfying.");
  762.         else
  763. #endif
  764.             if (u.ualigntyp != U_CHAOTIC)
  765.             pline("You'll regret this infamous offense!");
  766. #ifdef ALTARS
  767.         if (altaralign != U_CHAOTIC) {
  768.             /* curse the lawful/neutral altar */
  769.             pline("The altar is stained with human blood.");
  770.             levl[u.ux][u.uy].altarmask = A_CHAOS;
  771.             angry_priest();
  772.         } else {
  773.             register struct monst *dmon;
  774.     /* Human sacrifice on a chaotic altar is equivalent to demon summoning */
  775. # ifdef THEOLOGY
  776.             if (altaralign == U_CHAOTIC)
  777.                 pline("The blood covers the altar!");
  778.             else {
  779. # endif
  780.     pline("The blood floods over the altar, which vanishes in %s cloud!",
  781.                   an(Hallucination ? hcolor() : black));
  782.                 levl[u.ux][u.uy].typ = ROOM;
  783.                 levl[u.ux][u.uy].altarmask = 0;
  784. # ifdef THEOLOGY
  785.             }
  786. # endif
  787.             change_luck(2);
  788.             if(Invisible) newsym(u.ux, u.uy);
  789.             if(dmon = makemon(&mons[dlord()], u.ux, u.uy)) {
  790.                 You("have summoned a demon lord!");
  791.                 if (u.ualigntyp == U_CHAOTIC) 
  792.                     dmon->mpeaceful = 1;
  793.                 You("are terrified, and unable to move.");
  794.                 nomul(-3);
  795.             } else pline("The cloud dissipates.");
  796.         }
  797. #endif
  798.         if (u.ualigntyp != U_CHAOTIC) {
  799.             adjalign(-5);
  800.             u.ugangr += 3;
  801.             adjattrib(A_WIS, -1, TRUE);
  802.             if (!Inhell) angrygods();
  803.             change_luck(-5);
  804.         } else adjalign(5);
  805.         if (carried(otmp)) useup(otmp);
  806.         else useupf(otmp);
  807.         return(1);
  808.         } else if (is_undead(mtmp)) { /* Not demons--no demon corpses */
  809.         if (u.ualigntyp != U_CHAOTIC)
  810.             value += 1;
  811.         } else if (mtmp->mlet == S_UNICORN) {
  812.         int unicalign;
  813.  
  814.         if (mtmp == &mons[PM_BLACK_UNICORN]) unicalign = -1;
  815.         else if (mtmp == &mons[PM_GRAY_UNICORN]) unicalign = 0;
  816.         else if (mtmp == &mons[PM_WHITE_UNICORN]) unicalign = 1;
  817. #ifdef __GNULINT__
  818.         else { impossible("Bad unicorn type??"); unicalign = 0; }
  819. #endif
  820. #ifdef ALTARS
  821.         /* If same as altar, always a very bad action. */
  822.         if (unicalign == altaralign) {
  823.             pline("Such an action is an insult to %s!", (unicalign== -1)
  824.                 ? "chaos" : unicalign ? "law" : "neutrality");
  825.             adjattrib(A_WIS, -1, TRUE);
  826.             value = -5;
  827.         } else if (u.ualigntyp == altaralign) {
  828.         /* If different from altar, and altar is same as yours, */
  829.         /* get maximum alignment */
  830.             if (u.ualign < ALIGNLIM)
  831.             You("feel stridently %s!", (u.ualigntyp== U_CHAOTIC) ?
  832.                 "chaotic" : u.ualigntyp ? "lawful" : "neutral");
  833.             else You("feel you are thoroughly on the right path.");
  834.             u.ualign = ALIGNLIM;
  835.             value += 3;
  836.         } else
  837.         /* If sacrificing unicorn of your alignment to altar not of */
  838.         /* your alignment, your god gets angry and it's a conversion */
  839. #endif
  840.         if (unicalign == u.ualigntyp) {
  841.             u.ualign = -1;
  842.             value = 1;
  843.         } else value += 3;
  844.         }
  845.     }
  846. #ifdef ENDGAME
  847.     if (otmp->otyp == AMULET_OF_YENDOR) {
  848.         if (dlevel != ENDLEVEL) {
  849.         if (otmp->spe == 0) {
  850.             if (Hallucination)
  851.             You("feel homesick.");
  852.             else
  853.             You("feel an urge to return to the surface.");
  854.             return (1);
  855.         }
  856.         } else
  857.         if (otmp->spe < 0) {  /* fake! */
  858.             if (flags.soundok)
  859.             You("hear a nearby thunderclap.");
  860.             if (!otmp->known) {
  861.             You("realize you have made a %s.",
  862.                   Hallucination ? "boo-boo" : "mistake");
  863.             otmp->known = 1;
  864.             return (1);
  865.             } else {
  866.             /* don't you dare try to fool the gods */
  867.             change_luck(-3);
  868.             u.ugangr += 3;
  869.             value = -3;
  870.             }
  871.         }
  872.         else {
  873.             /* The final Test.    Did you win? */
  874.             if(uamul == otmp) Amulet_off();
  875.             if(carried(otmp)) useup(otmp);    /* well, it's gone now */
  876.             else useupf(otmp);
  877.             You("offer the Amulet to %s...", a_gname());
  878.             if (u.ualigntyp != altaralign) {
  879.             /* And the opposing team picks him up and
  880.                    carries him off on their shoulders */
  881.                pline("%s accepts your gift, and gains dominion over %s...",
  882.                   a_gname(), u_gname());
  883.             pline("%s is enraged...", u_gname());
  884.             pline("Fortunately, %s permits you to live...", a_gname());
  885.             pline("A cloud of %s smoke surrounds you...",
  886.                 Hallucination ? hcolor() : (const char *)"orange");
  887.             done(ESCAPED);
  888.             } else {        /* super big win */
  889.         pline("An invisible choir sings, and you are bathed in radiance...");
  890.             verbalize("Congratulations, mortal!");
  891.             more();
  892. verbalize("In return for thy service, I grant thee the gift of Immortality!");
  893.             You("ascend to the status of Demigod...");
  894.             done(ASCENDED);
  895.             }
  896.         }
  897.     }
  898. #endif /* ENDGAME */
  899.  
  900. #ifndef ALTARS    /* No altars in shops */
  901.     if (otmp->unpaid && u.ualigntyp != U_CHAOTIC) {
  902.         You("realize sacrificing what is not yours is a very chaotic act.");
  903.         value = -3;
  904.     }
  905. #endif
  906.  
  907.     if (value == 0
  908. #ifndef ALTARS
  909.                || Inhell
  910. #endif
  911.        ) {
  912.         pline(nothing_happens);
  913.         return (1);
  914.     }
  915.  
  916.     if (value < 0)  /* I don't think the gods are gonna like this... */
  917.         gods_upset();
  918.     else {
  919.  
  920.         int saved_anger = u.ugangr;
  921.         int saved_cnt = u.ublesscnt;
  922.         int saved_luck = u.uluck;
  923.         boolean consumed = FALSE;
  924. #ifdef ALTARS
  925.         /* Sacrificing at an altar of a different alignment */
  926.         if (u.ualigntyp != altaralign) {
  927.         /* Is this a conversion ? */
  928.         if(ugod_is_angry()) {
  929.             if(u.ualignbase[0] == u.ualignbase[1]) {
  930.             consume_offering(otmp);
  931.             You("have a strong feeling that %s is angry...",
  932.                     u_gname());
  933.             pline("%s accepts your allegiance.",a_gname());
  934.             You("have a sudden sense of a new direction.");
  935.             /* The player wears a helm of opposite alignment? */
  936.             if (uarmh && uarmh->otyp == HELM_OF_OPPOSITE_ALIGNMENT)
  937.                 u.ualignbase[0] = altaralign;
  938.             else
  939.                 u.ualigntyp = u.ualignbase[0] = altaralign;
  940.             flags.botl = 1;
  941.             /* Beware, Conversion is costly */
  942.             change_luck(-3);
  943.             u.ublesscnt += 300;
  944.             adjalign((int)(u.ualignbase[1] * (ALIGNLIM / 2)));
  945.             } else {
  946.             pline("%s rejects your sacrifice!", a_gname());
  947.             pline("The voice of %s booms:", u_gname());
  948.             verbalize("Suffer, infidel!");
  949.             adjalign(-5);
  950.             u.ugangr += 3;
  951.             adjattrib(A_WIS, -2, TRUE);
  952.             if (!Inhell) angrygods();
  953.             change_luck(-5);
  954.             }
  955.             return(1);
  956.          } else {
  957.             consume_offering(otmp);
  958.             consumed = TRUE;
  959.             You("sense a conflict between %s and %s.",
  960.                     u_gname(), a_gname());
  961.             if (rn2(8 + (int)u.ulevel) > 5) {
  962.             You("feel the power of %s increase.",
  963.                     u_gname());
  964.             change_luck(1);
  965.             /* Yes, this is supposed to be &=, not |= */
  966.             levl[u.ux][u.uy].altarmask &= A_SHRINE;
  967.             /* the following accommodates stupid compilers */
  968.             levl[u.ux][u.uy].altarmask =
  969.                 levl[u.ux][u.uy].altarmask | (u.ualigntyp + 1);
  970.             if (!Blind)
  971.                 pline("The newly consecrated altar glows %s.",
  972.                 Hallucination ? hcolor() :
  973.                 u.ualigntyp == U_LAWFUL ? white :
  974.                 u.ualigntyp ? black : (const char *)"gray");
  975.             } else {
  976.             pline("Unluckily, you feel the power of %s decrease.",
  977.                     u_gname());
  978.             change_luck(-1);
  979.             }
  980.             return(1);
  981.         }
  982.         }
  983. #endif
  984.         if(!consumed) consume_offering(otmp);
  985.         /* OK, you get brownie points. */
  986.         if(u.ugangr) {
  987.         u.ugangr -= ((value * (u.ualigntyp == U_CHAOTIC ? 2 : 3)) / MAXVALUE);
  988.         if(u.ugangr < 0) u.ugangr = 0;
  989.         if(u.ugangr != saved_anger) {
  990.             if (u.ugangr) {
  991.             if(Hallucination)
  992.                 pline("The gods seem %s.", hcolor());
  993.             else pline("The gods seem slightly mollified.");
  994.  
  995.             if ((int)u.uluck < 0) change_luck(1);
  996.             } else {
  997.             if (Hallucination)
  998.                 pline("The gods seem cosmic (not a new fact).");
  999.             else pline ("The gods seem mollified.");
  1000.  
  1001.             if ((int)u.uluck < 0) u.uluck = 0;
  1002.             }
  1003.         } else {  /* not satisfied yet */
  1004.             if (Hallucination)
  1005.                 pline("The gods seem tall.");
  1006.             else You("have a feeling of inadequacy.");
  1007.         }
  1008.         }
  1009.         else if (u.ublesscnt > 0) {
  1010.         u.ublesscnt -= ((value * (u.ualigntyp == U_CHAOTIC ? 500 : 300))
  1011.                 / MAXVALUE);
  1012.         if(u.ublesscnt < 0) u.ublesscnt = 0;
  1013.         if(u.ublesscnt != saved_cnt) {
  1014.  
  1015.             if (u.ublesscnt) {
  1016.             if (Hallucination)
  1017.             You("realize that the gods are not like you and I.");
  1018.             else
  1019.                     You("have a hopeful feeling.");
  1020.             if ((int)u.uluck < 0) change_luck(1);
  1021.             } else {
  1022.             if (Hallucination)
  1023.             pline("Overall, there is a smell of fried onions.");
  1024.             else
  1025.                 You("have a feeling of reconciliation.");
  1026.             if ((int)u.uluck < 0) u.uluck = 0;
  1027.             }
  1028.         }
  1029.         } else {
  1030.         /* you were already in pretty good standing */
  1031. #if defined(ALTARS) && defined(NAMED_ITEMS)
  1032.         /* The player can gain an artifact */
  1033.         if(!rn2(10)) {
  1034.             otmp = mk_aligned_artifact((unsigned)(levl[u.ux][u.uy].altarmask & ~A_SHRINE));
  1035.             if(otmp) {
  1036.                 if (otmp->spe < 0) otmp->spe = 0;
  1037.                 if (otmp->cursed) otmp->cursed = 0;
  1038.                 dropy(otmp);
  1039.                 pline("An object appears at your %s!",
  1040.                   makeplural(body_part(FOOT)));
  1041.                 return(1);
  1042.             }
  1043.         }
  1044. #endif
  1045.         change_luck((value * LUCKMAX) / (MAXVALUE * 2));
  1046.         if (u.uluck != saved_luck) {
  1047.             if (Blind)
  1048.             You("think something brushed your %s.",
  1049.                 body_part(FOOT));
  1050.             else You(Hallucination ?
  1051.         "see crabgrass at your %s.  A funny thing in a dungeon." :
  1052.         "glimpse a four-leaf clover at your %s.",
  1053.             makeplural(body_part(FOOT)));
  1054.         }
  1055.         }
  1056.     }
  1057.     return(1);
  1058. }
  1059.  
  1060. int
  1061. dopray() {        /* M. Stephenson (1.0.3b) */
  1062.     int trouble = in_trouble();
  1063. #ifdef ALTARS
  1064.        int aligntyp =
  1065.         on_altar() ?
  1066.             (int)(levl[u.ux][u.uy].altarmask & ~A_SHRINE) - 1 :
  1067.             u.ualigntyp;
  1068.        int align;
  1069.  
  1070.     if (u.ualigntyp && u.ualigntyp == -aligntyp) align = -u.ualign;
  1071.         /* Opposite alignment altar */
  1072.     else if (u.ualigntyp != aligntyp) align = u.ualign / 2;
  1073.         /* Different (but non-opposite) alignment altar */
  1074.     else align = u.ualign;
  1075. #else
  1076.       int aligntyp = u.ualigntyp;
  1077.       int align = u.ualign;
  1078. #endif
  1079.  
  1080. #ifdef POLYSELF
  1081.     if (is_undead(uasmon)) {
  1082.         if (aligntyp == 1 || (aligntyp == 0 && !rn2(10))) {
  1083.             verbalize(aligntyp == 1 ?
  1084.                   "Vile creature, thou durst call upon me?" :
  1085.                   "Walk no more, perversion of nature!");
  1086.             You("feel like you are falling apart.");
  1087.             rehumanize();
  1088.             losehp(rnd(20), "residual undead turning effect",
  1089.                 KILLED_BY_AN);
  1090.             return(1);
  1091.         }
  1092.     }
  1093.     if (is_demon(uasmon) && (aligntyp != -1)) {
  1094.         pline("The very idea of praying to a %s god is repugnant to you.",
  1095.             u.ualigntyp ? "lawful" : "neutral");
  1096.         return(0);
  1097.     }
  1098. #endif
  1099.     if (Inhell && u.ualigntyp != U_CHAOTIC) {
  1100.         pline("Since you are in hell, %s won't help you.",
  1101. #  ifdef ALTARS
  1102.             on_altar() ?  a_gname() :
  1103. #  endif
  1104.                         u_gname());
  1105.         aggravate();
  1106.         return(0);
  1107.     }
  1108.  
  1109. #ifdef WIZARD
  1110.     if (wizard) {
  1111.         pline("Force the gods to be pleased? ");
  1112.         if (yn() == 'y') {
  1113.             u.ublesscnt = 0;
  1114.             if (u.uluck < 0) u.uluck = 0;
  1115.             u.ugangr = 0;
  1116.             if (align < 1) align = 1;
  1117.         }
  1118.     }
  1119. #endif
  1120.     if ((!trouble && (u.ublesscnt > 0)) ||
  1121.         ((trouble < 0) && (u.ublesscnt > 100)) /* minor difficulties */ ||
  1122.         ((trouble > 0) && (u.ublesscnt > 200)) /* big trouble */
  1123.         ) {
  1124.         u.ublesscnt += rnz(250);
  1125.         change_luck(-3);
  1126.         gods_upset();
  1127.     } else if ((int)Luck < 0 || u.ugangr || align < 0)
  1128.         angrygods();            /* naughty */
  1129.     else    if (align >= 0) pleased();    /* nice */
  1130.     nomovemsg = "You finish your prayer.";
  1131.     nomul(-3);
  1132.     return(1);
  1133. }
  1134. #endif /* THEOLOGY */
  1135.  
  1136. int
  1137. doturn()
  1138. {    /* Knights & Priest(esse)s only please */
  1139.  
  1140.     register struct monst *mtmp;
  1141.     register int    xlev = 6;
  1142.  
  1143.     if((pl_character[0] != 'P') &&
  1144.        (pl_character[0] != 'K')) {
  1145. #ifdef SPELLS
  1146.         /* Try to use turn undead spell. */
  1147.         if (objects[SPE_TURN_UNDEAD].oc_name_known) {
  1148.             register int sp_no;
  1149.             for (sp_no = 0; sp_no < MAXSPELL &&
  1150.                 spl_book[sp_no].sp_id != NO_SPELL &&
  1151.                 spl_book[sp_no].sp_id != SPE_TURN_UNDEAD; sp_no++);
  1152.  
  1153.             if (sp_no < MAXSPELL &&
  1154.             spl_book[sp_no].sp_id == SPE_TURN_UNDEAD)
  1155.                 return spelleffects(++sp_no, TRUE);
  1156.         }
  1157. #endif
  1158.  
  1159.         You("don't know how to turn undead!");
  1160.         return(0);
  1161.     }
  1162. #if defined(POLYSELF) || defined(THEOLOGY)
  1163.     if (
  1164. #  ifdef POLYSELF
  1165.         (u.ualigntyp != U_CHAOTIC && (is_demon(uasmon) || is_undead(uasmon)))
  1166. #  endif
  1167. #  if defined(POLYSELF) && defined(THEOLOGY)
  1168.         ||
  1169. #  endif
  1170. #  ifdef THEOLOGY
  1171.         u.ugangr > 6 /* "Die, mortal!" */
  1172. #  endif
  1173.         ) {
  1174.  
  1175.         pline("For some reason, the gods seem to ignore you.");
  1176.         aggravate();
  1177.         return(0);
  1178.     }
  1179. #endif
  1180.     if (Inhell && u.ualigntyp != U_CHAOTIC) {
  1181. #ifdef THEOLOGY
  1182.         pline("Since you are in hell, %s won't help you.", u_gname());
  1183. #else
  1184.         pline("Since you are in hell, the gods won't help you.");
  1185. #endif
  1186.         aggravate();
  1187.         return(0);
  1188.     }
  1189. #ifdef THEOLOGY
  1190.     pline("Calling upon %s, you chant an arcane formula.", u_gname());
  1191. #else
  1192.     pline("Calling upon the gods, you chant an arcane formula.");
  1193. #endif
  1194.     for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  1195.         if(cansee(mtmp->mx,mtmp->my)) {
  1196.         if(!mtmp->mtame && !mtmp->mpeaceful && (is_undead(mtmp->data) ||
  1197.            (is_demon(mtmp->data) && (u.ulevel > (MAXULEV/2))))) {
  1198.  
  1199.             if(Confusion) {
  1200.             pline("Unfortunately, your voice falters.");
  1201.             mtmp->mflee = mtmp->mfrozen = mtmp->msleep = 0;
  1202.             mtmp->mcanmove = 1;
  1203.             } else if (! resist(mtmp, '\0', 0, TELL))
  1204.             switch (mtmp->data->mlet) {
  1205.                 /* this is intentional, lichs are tougher
  1206.                    than zombies. */
  1207.                 case S_LICH:    xlev += 2;
  1208.                 case S_GHOST:   xlev += 2;
  1209.                 case S_VAMPIRE: xlev += 2;
  1210.                 case S_WRAITH:  xlev += 2;
  1211.                 case S_MUMMY:   xlev += 2;
  1212.                 case S_ZOMBIE:
  1213.                 mtmp->mflee = 1; /* at least */
  1214.                 if(u.ulevel >= xlev)  {
  1215.                     if(!resist(mtmp, '\0', 0, NOTELL)) {
  1216.                     if(u.ualigntyp == U_CHAOTIC) {
  1217.                         mtmp->mpeaceful = 1; /* make them friendly */
  1218.                     } else { /* damn them */
  1219.                         You("destroy %s!", mon_nam(mtmp));
  1220.                         mondied(mtmp);
  1221.                     }
  1222.                     }
  1223.                 }
  1224.                 break;
  1225.                 default:    mtmp->mflee = 1;
  1226.                     break;
  1227.             }
  1228.            }
  1229.         }
  1230.         nomul(-5);
  1231.         return(1);
  1232. }
  1233.  
  1234. #ifdef ALTARS
  1235. const char *
  1236. a_gname()
  1237. {
  1238.     return(a_gname_at(u.ux, u.uy));
  1239. }
  1240.  
  1241. const char *
  1242. a_gname_at(x,y)     /* returns the name of an altar's deity */
  1243. xchar x, y;
  1244. {
  1245.     register int align;
  1246.  
  1247.     if(!IS_ALTAR(levl[x][y].typ)) return((char *)0);
  1248.  
  1249.     align = levl[x][y].altarmask & ~A_SHRINE;
  1250. # ifdef THEOLOGY
  1251.        {struct ghods *aghod;
  1252.  
  1253.     for(aghod=gods; aghod->classlet; aghod++)
  1254.         if(aghod->classlet == pl_character[0])
  1255.         switch(align) {
  1256.         case A_CHAOS:    return(aghod->chaos);
  1257.         case A_NEUTRAL:    return(aghod->balance);
  1258.         case A_LAW:    return(aghod->law);
  1259.         default: impossible("unknown altar alignment.");
  1260.              return("Balance");
  1261.         }
  1262.     impossible("Altar to unknown character's god?");
  1263.     return("someone");
  1264.        }
  1265. # else
  1266.     switch(align) {
  1267.     case A_CHAOS:    return("Chaos");
  1268.     case A_NEUTRAL:    return("Balance");
  1269.     case A_LAW:    return("Law");
  1270.     default: impossible("unknown altar alignment.");
  1271.          return("Balance");
  1272.     }
  1273. # endif /* THEOLOGY */
  1274. }
  1275.  
  1276. # ifdef THEOLOGY
  1277. void
  1278. altar_wrath(x, y)
  1279. register int x, y;
  1280. {
  1281.     if(!strcmp(a_gname_at(x,y), u_gname())) {
  1282.         pline("The voice of %s booms:", a_gname_at(x,y));
  1283.         verbalize("How darest thou desecrate my altar!");
  1284.         adjattrib(A_WIS, -1, FALSE);
  1285.     } else {
  1286.         pline("A voice whispers in your ear:");
  1287.         verbalize("Thou shalt pay, infidel!");
  1288.         change_luck(-1);
  1289.     }
  1290. }
  1291. # endif /* THEOLOGY */
  1292. #endif /* ALTARS */
  1293.  
  1294. #ifdef THEOLOGY
  1295. const char *
  1296. u_gname() {  /* returns the name of the player's deity */
  1297.     register struct ghods *aghod;
  1298.  
  1299.     for(aghod=gods; aghod->classlet; aghod++)
  1300.         if(aghod->classlet == pl_character[0])
  1301.         switch(u.ualigntyp) {
  1302.         case  1: return(aghod->law);
  1303.         case  0: return(aghod->balance);
  1304.         case -1: return(aghod->chaos);
  1305.         default: impossible("unknown character alignment.");
  1306.              return("Balance");
  1307.         }
  1308.     impossible("atheist player?");
  1309.     return("someone");
  1310. }
  1311. #endif /* THEOLOGY */
  1312.